package cn.felord.debezium.annotation;

import cn.felord.debezium.config.DebeziumServerBootstrap;
import cn.felord.debezium.handle.columnHandle.ColumnHandleExecutor;
import io.debezium.embedded.Connect;
import io.debezium.engine.DebeziumEngine;
import io.debezium.engine.RecordChangeEvent;
import io.debezium.engine.format.ChangeEventFormat;
import org.apache.kafka.connect.source.SourceRecord;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.ServiceLoader;

@Configuration
public class ExecutorInspect {
    @Resource
    private ApplicationContext applicationContext;
    @Bean
    void ExecutorInspect() {
        Map<String, ColumnHandleExecutor> beansOfType = applicationContext.getBeansOfType(ColumnHandleExecutor.class);
        beansOfType.entrySet().forEach(x->{
            if (x.getValue().getClass().getAnnotation(Executor.class)==null) {
                throw new RuntimeException("ColumnHandleExecutor实现类: "+x.getValue().getClass().toString()+"  未添加注解@Executor");
            }
        });

    }
}
